package fr.umlv.galcon.ship;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Shape;
import java.awt.geom.Point2D;

import fr.umlv.galcon.item.GraphicItem;

public abstract class ShipAbstract implements GraphicItem {

    private Point2D center;
    private final int width;
    private final ShipProperties shipProperties;
    private final Squadron squadron;

    private final ShipMovement shipMovement;

    private boolean isRemoved;

    private final ShipSelectorManager shipSelectorManager;

    /**
     * Constructor
     * 
     * @param x
     *            X coordinate of the Ship.
     * @param y
     *            Y coordinate of the Ship.
     * @param width
     *            Width of Ship.
     * @param shipProperties
     *            Properties of the Ship.
     * @param squadron
     *            Squadron which contains the Ship.
     */
    protected ShipAbstract(int x, int y, int width, ShipProperties shipProperties, Squadron squadron) {
	this.center = new Point(x, y);
	this.width = width;
	this.shipProperties = shipProperties;
	this.squadron = squadron;
	this.isRemoved = false;
	this.shipMovement = new ShipMovement(this, this.center);
	this.shipSelectorManager = new ShipSelectorManager(squadron);
    }

    @Override
    public abstract void draw(Graphics2D graphics);

    @Override
    public abstract boolean intersect(GraphicItem item);

    @Override
    public abstract Shape getShape();

    /**
     * Get the ship center
     * 
     * @return center
     */
    public Point2D getCenter() {
	return center;
    }

    /**
     * get the Ship width
     * 
     * @return width
     */
    public int getWidth() {
	return width;
    }

    /**
     * Get the ship properties
     * 
     * @return properties
     */
    public ShipProperties getShipProperties() {
	return shipProperties;
    }

    /**
     * Get the ship's squadron
     * 
     * @return squadron
     */
    public Squadron getSquadron() {
	return squadron;
    }

    /**
     * Get the ship's removed state
     * 
     * @return true if it is remove, else false
     */
    public boolean isRemoved() {
	return isRemoved;
    }

    /**
     * Set the ship's removed state
     * 
     * @param isRemoved
     */
    public void setRemoved(boolean isRemoved) {
	this.isRemoved = isRemoved;
    }

    /**
     * Set the ship' center
     * 
     * @param center
     */
    public void setCenter(Point2D center) {
	this.center = center;
    }

    /**
     * Get the ship's movement
     * 
     * @return ship movement
     */
    public ShipMovement getShipMovement() {
	return shipMovement;
    }

    /**
     * Get the ship selector manager
     * 
     * @return selector manager
     */
    public ShipSelectorManager getShipSelectorManager() {
	return shipSelectorManager;
    }

}
